<input type="file" id="upload_file" name="">

<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
    /// ajax 上传图片
    function uploadFile() {
        var _file = this;
        var data = new FormData();
        data.append('image', _file.files[0]);

        URL_fileUpload = "http://localhost/hx_tqd/web/app_dev.php/api/public/upload_image";
        $.ajax({
            url:URL_fileUpload,
            type: 'POST',
            dataType: 'json',
            processData: false,
            contentType: false,
            data: data,
            success: function (data) {
                if(data.errorCode == 0){
                    banner_path = data.data.path;

                    console.log(banner_path);
                } else {
                    alert(data.message);
                    return false;
                }
            }
        });
    }
    $("#upload_file").on("change", uploadFile);
</script>